package com.sr.recitewords.utils;

import org.springframework.util.DigestUtils;

import java.util.UUID;

public class MD5EncryptUtils {

    public static String encryptHaveSalt(String password, String salt) {
        String finalPassword = DigestUtils.md5DigestAsHex((salt + password).getBytes());
        return finalPassword;
    }

    public static boolean checkEncryptHaveSalt(String oldCiphertext, String ciphertext) {
        String salt = oldCiphertext.substring(0, 32);
        String newCiphertext = DigestUtils.md5DigestAsHex((salt + ciphertext).getBytes());
        return oldCiphertext.equals(salt + newCiphertext);
    }


}
